a=int(input())
if a<1000 and a>9999:
    d = 0
    for i in range(2,a):
        if a % i == 0:
             d +=1
    if d == 0:
        print(a)
    else:
        print(0)
else:
    print(0)
       
